home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14495 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: wmin.ac.uk!usenet
  2. From: Idoia Lertxundi <gsoec@wmin.ac.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: (no subject)
  5. Date: 15 Apr 1996 12:07:11 GMT
  6. Organization: Westminster University
  7. Message-ID: <4kte5f$1t2@badger.wmin.ac.uk>
  8. NNTP-Posting-Host: ux213.wmin.ac.uk
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.3_U1 sun4m)
  13. X-URL: news:comp.lang.c/154383-154482
  14.  
  15. Hi C sufferers/lovers,
  16.  
  17. I am working in the C program and I have come accross a weird prob.
  18. Rather than sending you code I will explain it in English as I have
  19. accurately located the problem.
  20.  
  21. I have a list which is being created dinamycally and a pointer pointing to
  22. the head of the list.
  23.  
  24. ptr=AllocateSpaceforptr();
  25. head=ptr;
  26.  
  27.  head  ptr....ptr
  28.  |   !   !  |
  29.  {}-{}-{}-NULL
  30.  
  31.   1  2  3  4
  32.  
  33. When I have put data in node number 3 I allocate with a malloc call
  34. node number 4 and as the function do not find suitable data to put
  35. in number 4 after a for loop I assign it to NULL. i.e.
  36.  
  37.      ptr=(FILEMODULE *)NULL;
  38.  
  39. When I do printfs I see that the list of ptr corresponds to what I was
  40. expecting the above picture when I print out the content of the head pointer
  41. list
  42. which points to the begining of the ptr list the result is unexpected.
  43. i.e.
  44.  
  45. head
  46.  |
  47.  {}-{}-{}-[not defined] the last node instead of being NULL is not defined.
  48.  
  49.  
  50.   1  2  3  4
  51.  
  52. By not defined I mean that is a if after malloc there has not been anything
  53. put in there although I put the NULL which shows perfectly well in the ptr
  54. list. Somehow the head list is not receiving the NULL asigment. WHY??
  55.  
  56. Any ideas you please mail me. I am sending this to a Newsgroup too.
  57.  
  58. Thank you.
  59.  
  60. P.S. The order is Read data to allocated, allocate a new one and traverse.
  61.  
  62. --
  63. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. Ms Idoia Lertxundi                              .            ,
  65.                                                             .:/
  66. e-mail: gsoec@wmin.ac.uk                           .      ,,///;,   ,;/
  67. URL   : http://www.wmin.ac.uk/~gsoec/                .   o:::::::;;///
  68.                                                         >::::::::;;\\\
  69.                                                          `'\\\\\'" `;\
  70.                                                             `;\
  71. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72. "All philosophy," I told her, "is based on two things only:
  73.  curiosity and poor eyesight; if you had better eyesight you could see
  74.  perfectly well whether or not these stars are solar systems, and if
  75.  you were less curious you wouldn't care about knowing, which amounts
  76.  to the same thing. The trouble is, we want to know more than we can see."
  77.  
  78. Bernard de Fontanelle, Conversations on the Plurality of Worlds.
  79.  
  80.